package com.nexus.service.sys.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.nexus.core.exception.ServiceException;
import com.nexus.core.service.TreeService;
import com.nexus.core.sys.dto.SysDictTypeDTO;
import com.nexus.core.sys.entity.SysDictType;
import com.nexus.service.sys.mapper.SysDictTypeMapper;
import com.nexus.service.sys.service.mapstruct.SysDictTypeWrapper;
import org.springframework.transaction.annotation.Transactional;

/**
 * 系统字典TypeService
 *
 * @author 路正宁
 * @version 2023-03-15
 */
//@DS("zxhy_platform_db")
//@Service
@Transactional(rollbackFor = {ServiceException.class, Exception.class, RuntimeException.class})
public class SysDictTypeService extends TreeService<SysDictTypeMapper, SysDictType, SysDictTypeDTO, SysDictTypeWrapper> {

    /**
     * 根据id查询
     *
     * @param id
     * @return
     */
    public SysDictTypeDTO findById(String id) {
        return baseMapper.findById(id);
    }

    /**
     * 自定义分页检索
     *
     * @param page
     * @param queryWrapper
     * @return
     */
    public IPage<SysDictTypeDTO> findPage(Page<SysDictTypeDTO> page, QueryWrapper queryWrapper) {
        queryWrapper.eq("a.deleted", 0); // 排除已经删除
        return baseMapper.findList(page, queryWrapper);
    }

}
